package work20241120;

import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/20
 */
public class Demo8 {
    public static void main(String[] args) {
        /**
         * 8.综合练习：卖飞机票
         *     需求:机票价格按照淡季旺季、头等舱和经济舱收费、输入机票原价、月份和头等舱或经济舱。
         *     按照如下规则计算机票价格:旺季（5-10月）头等舱9折，经济舱8.5折，淡季(11月到来年4月）头等舱7折，经济舱6.5折。
         */
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的机票原价：");
        double price = sc.nextDouble();
        System.out.println("请输入你的购买机票月份（1-12）：");
        int month = sc.nextInt();
        System.out.println("请输入(0:头等舱，1:经济舱)：");
        int num = sc.nextInt();
        if (num > 1 || num < 0 || month < 0 || month > 12) {
            System.out.println("输入有误");
            System.exit(0);
        }
        switch (month) {
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                if (num == 0) {
                    String s = zheKou(price, 0.9);
                    System.out.println(s);
                }
                break;
            case 11:
            case 12:
            case 1:
            case 2:
            case 3:
            case 4:
                if (num == 1) {
                    String s = zheKou(price, 0.85);
                    System.out.println(s);
                }
                break;
            default:
                System.out.println("你还是原价机票");
        }
    }
    public static String zheKou(double price, double daZhe) {
        double zhekou = price * daZhe;
        return "你的机票最终价格为:" + zhekou;
    }
}


